﻿
using Wedonek.RpcStore.Service.DAL;
using Wedonek.RpcStore.Service.Interface;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Service.Collect
{
        internal class ErrorLangMsgCollect : BasicCollect<ErrorLangMsgDAL>, IErrorLangMsgCollect
        {
                public ErrorLang[] GetErrorMsg (long[] errorId)
                {
                        return this.BasicDAL.GetErrorMsg (errorId);
                }
                public ErrorLang[] GetErrorMsg (long[] errorId,string lang)
                {
                        return this.BasicDAL.GetErrorMsg (errorId,lang);
                }
                private long _FindErrorLangId (long errorId, string lang)
                {
                        return this.BasicDAL.GetErrorLangId (errorId, lang);
                }
                private void _SetErrorMsg (long id, string msg)
                {
                        this.BasicDAL.SetErrorMsg (id, msg);
                }
                public void SyncError (long errorId, string lang, string msg)
                {
                        long id = this._FindErrorLangId (errorId, lang);
                        if (id != 0)
                        {
                                this._SetErrorMsg (id, msg);
                                return;
                        }
                        this.BasicDAL.AddErrorMsg (new ErrorLangAddParam
                        {
                                ErrorId = errorId,
                                Lang = lang,
                                Msg = msg
                        });
                }
                public string GetErrorMsg (long errorId, string lang)
                {
                        return this.BasicDAL.GetErrorMsg (errorId, lang);
                }
        }
}
